home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
BUSINESS
/
TAS206.ARJ
/
TAS.TXT
< prev
next >
Wrap
Text File
|
1991-02-17
|
79KB
|
1,824 lines
1 Introduction
"Technical Analysis Scanner(tm)" (TAS) is a software program that gives
you control of your MetaStock (or ChartPro) data base using Technical
Analysis Indicators and conditional relationships to "scan" all, or a
portion, of your data files. TAS also contains an optional Profit Testing
Facility (referred to as TAS/PT).
TAS is a generalized Technical Analysis scanning tool. It is not a "black
box" system. You have complete control over the indicators chosen, their
interpretation, and the output format for your reports.
With TAS, you can combine many Technical Indicators, compare their values
against other indicators or values, make decisions based on the result of
those comparisons, and ultimately, create a report which shows you what
you want to see.
TAS is designed to enable you to go beyond the MetaStock Pro "Custom
Formulas" by applying similar analysis to all or any part of the data in
your Metastock (or ChartPro) Data Base. If you have a profit formula you
believe is appropriate, but you do not have the time to chart all of your
stocks everyday, then TAS is the tool you need. It runs your customized
formula on selected groups of your stocks, and can be used to notify if
your buy or sell trigger is "crossed".
TAS can also be used to create custom reports on your stocks. For example,
you can use it to notify you when a particular stock has reached a certain
price, volume or Technical Indicator value.
When the optional Profit Tester feature (TAS/PT) is enabled, you can
confirm the profitability of your system using TAS/PT.
2 Taking Care of Business
2.1 Registration
TAS is distributed as a TRIAL version. The TRIAL version of TAS has the
following restrictions:
1) Only 20 TICKER symbols will be accessed from a "TICKER
LIST"
2) TAS cannot be run from a batch file as a DOS command
3) You cannot redirect the output from the TAS reports into a
file or to the printer.
4) Only one TICKER will be allowed to be used with the Profit
Test feature (TAS/PT).
5) The functions listed below may not be available in the
TRIAL version.
Directional Movement - PDI, MDI, DX, ADX, ADXR
Linear Regression - LINREG, CORRCOEF, ANGLE, SLOPE
Intersection - OVER, ISECT
Profit Tester - BUY, SELL, STOP, TOTAL
Miscellaneous - MACD, MACDTRIGGER, CCI, VOL(atility)
When you register TAS, you will receive a "REGISTRATION CODE" that will
enable the full set of TAS features. If you register TAS/PT, there is
no limit on the number of TICKERs on which you can run the Profit Test
feature.
You will find that running TAS from a batch file and placing the
reports into a file for inspection is more convenient on a day-to-day
basis than running the program interactively. This particular feature,
as well as the ability to scan up to 2000 stocks in one run, should
encourage you to register your version of TAS.
Your registration entitles you to continuous updates for new TAS
features, support for TAS problems, questions and requests for new
indicators.
2.1.1 How to Register
In order to become a registered user of TAS or TAS/PT, please send a
check (made out to FlexSoft) for the amount of the registration fee
to:
FlexSoft
7172 Regional St, #276
Dublin, CA 94568
2.1.2 Registration Fee
If you register TAS alone, the registration cost is $45. If you want
TAS to include the Profit Testing support, the cost is $75.
If you have registered PML (another product of the author's)
directly through the author (rather than in a co-sponsored package),
your TAS registration cost is $35 and the cost for TAS/PT is $60.
If you wish to register PML and TAS together, the cost for both is
$60. Finally, the cost for PML and TAS/PT is $85.
TAS/PT is the TAS program with the Profit Test feature enabled.
There is no separate program for TAS/PT. I could have created a
separate program for the Profit tester feature, in which case, there
would have been a separate registration required for it. For the
convenience of everyone, I chose to include the Profit Tester in TAS
with a different Registration Code to enable it. This means you
don't have to download multiple files to get both features. Also,
you can upgrade your TAS to TAS/PT by just sending me the difference
in the Registration Cost. If you do not want the Profit Tester
feature, then the price for TAS is the same as it always has been.
The following table summarizes the registration pricing for TAS and
TAS/PT according to the discussion above.
TAS TAS/PT (profit tester)
----- ------
Non-PML User $45 $75
PML User $35 $60
plus PML $60 $85
2.2 Support
You can get support for TAS problems or questions by contacting me at
my mailing address (above) or by Email on the following services:
GEnie : M.MOORE41
Prodigy : JBMD65A
Compuserve : 76447,2367
MCI : M.MOORE
If you need a new version of TAS, it will be available on the FlexSoft
BBS at 415-829-2293 (HOURS 4-7 a.m. and 3:30-7 p.m. Pacific Time or by
special arrangement). You are entitled to free updates to TAS from this
BBS or by U.S. Mail (not including shipping and handling). If you need
an update by U.S. Mail, please send $5 for shipping and handling.
2.3 Redistribution of TAS
You may (and are encouraged to) re-distribute TAS to other BBS systems
as long as you redistribute the entire unmodified package as you
received it. You may not redistribute your registration code along with
the package, nor may you give it away as long as you are currently
using it.
2.4 Credits
MetaStock Professional is a stock charting program from Equis Inc.
ChartPro is a stock charting program written by David Rettger.
2.5 Disclaimers
The author claims no responsibility for any damages caused by the use
or misuse of this product. This product is distributed "as is" with no
warranty expressed or implied. The author will not be responsible for
any losses incurred, either directly or indirectly, by the use of this
product. The author reserves the right to make modifications at any
time. Prices are subject to change without notice.
3 Installation
TAS is distributed as a .ZIP format collection of files. The name of the
.ZIP file will be based on the version and release level of TAS. For
version 1, release 1, the name will be 'TAS101.ZIP', and in general, the
name will be 'TASvrr.ZIP' where 'v' is the Version and 'r' is the Release.
3.1 Quick Start Installation
The following "quick start" documentation shows how to get TAS up and
running on your system initially. The file name for the TAS ZIP file is
referred to as "TASvrr.ZIP".
In order to install TAS, you should perform the following steps
1) Create a directory to contain TAS software. It can be any name you
choose. The following instructions assume the subdirectory name is
"\TAS".
2) PKUNZIP TASvrr.ZIP into directory \TAS
3) CD \TAS
4) Type TAS
5) You will be presented with a menu.
6) Select "Configure TAS"
Fill in the MSP directory names you want to scan. You can enter up
to 5 subdirectories
Hit F3
7) Go to the "Define Ticker List" Menu
Select "Create New Ticker List"
Give the name "MYTICKS"
Move the cursor to each ticker symbol you want to run a script
against.
Hit the SPACE bar on the symbol.
It should highlight (indicating it is selected).
Hit F3 when all desired symbols are selected.
8) At the Main Menu, select Build or Run Selection by typing "B"
9) Reply to the New/Old prompt by typing "O" (for 'old').
Pick the selection MSURANK.SEL (by typing "M" or moving the
cursor to it) and hitting ENTER.
Pick the ticker list you just created "MYTICKS.TCK"
10) You will see the MSURANK selection values. This particular
selection will create a report like the one Metastock Utility (MSU)
creates when you select "Rank" using a 26 day Rate of Change and a
10 day Moving Average.
11) Hit the F4 Key to run the selection. As each ticker is processed,
you will see a line in the "run" window. Once all tickers are
processed, the report will be presented on the screen, sorted by
ticker.
12) Hit F1 now to see the choices you have. By hitting F1, you can read
the help and see what you can do from here. You can sort your
tickers on the value of any column shown, either ascending or
descending order. To sort on the values in the second column, press
the key sequence "Alt-2" (hold the ALT key and hit the number 2).
13) To exit from the report screen, hit the ESC key.
The documentation for the system is currently in the online help file
available by hitting the F1 key at any time.
4 TAS Invocation
You can start TAS in "MENU MODE" by simply typing "TAS" by itself. TAS has
switches available which you can specify on the command line. They are:
-c Eliminate CGA "snow"
-b Use BIOS to write to video screen. This may be necessary on some
systems which are not 100% compatible.
-m Use Monochrome color scheme
If you are a registered user of TAS, you can also start TAS in "batch
mode" by specifying the name of a SCRIPT and the Ticker file on the
command line. So, if you had a TAS script named "SELECT.TAS" and a Ticker
List named "MYSTOCK.TCK", you could run the SELECT script against the
stocks in the list MYSTOCK by typing:
TAS SELECT MYSTOCK
If you wanted TAS to process all of the stock symbols (Tickers) in your
data base, you can omit the Ticker List name.
If you need to use the video flags mentioned above, they should be
specified prior to the name of the script file.
5 TAS Menu Functions
The TAS Main Menu contains a screen which has all the options you can choose
when you work with TAS. The Main Menu looks like this:
╔════════Technical Analysis Scanner (TAS 2.5) Copyright 1990, FlexSoft══════╗
║ TRIAL VERSION ║
║ ║
║ ║
║ ┌───────────────Main Menu───────────────┐ ║
║ │ │ ║
║ │ │ ║
║ │ Configure TAS │ ║
║ │ │ ║
║ │ Define Ticker List │ ║
║ │ │ ║
║ │ Build or Run Selection │ ║
║ │ │ ║
║ │ Edit A TAS Script │ ║
║ │ │ ║
║ │ Run TAS Script │ ║
║ │ │ ║
║ │ Quit │ ║
║ │ │ ║
║ └───────────────────────────────────────┘ ║
║ ║
║ ║
╚═══════════════════════════════════════════════════════════════════════════╝
░[F1]=Help░░░░░░░░░░░░░░░░░░░░░Select Choice░░░░░░░░░░░░░░░░░[ESC]=Quit░░░
The following sections will describe each of the options accessible from the
Main Menu.
5.1 Configuration
The Configuration Menu is the place where you tell TAS the location of
your Metastock or ChartPro Data Directory(ies). Up to five directories
can be processed at one time.
The configuration menu looks like this:
TAS Configuration and Setup
|
|
| 1st Data DIRECTORY \MSPTEST\DATA
| 2nd Data DIRECTORY
| 3rd Data DIRECTORY
| 4th Data DIRECTORY
| 5th Data DIRECTORY
|
| Symbol Table Size 9000 Quotes per Symbol 150
|
| Your Name Martin Moore
| Registration Code xxxxx
You should fill in the names of your Metastock or ChartPro Directories,
one per line above. Be sure to include the full path name, including
the first backslash character. If you have more than one directory of
data files, you can enter the other directory names on the second thru
fifth lines.
Note that you cannot intermix directories across products. In other
words, all your directories must be either Metastock format or ChartPro
format. TAS determines the type of directory by first looking for a
file named "MASTER". If found, it assumes the directory is Metastock
format. If not found, it looks for files ending with ".PRO". If these
are found, it assumes that the directory is ChartPro data. If neither
search is satisfied, TAS issues an error message and requests that you
change the directory name.
The SYMBOL TABLE SIZE parameter is a "tuning" value which determines
the size of the internal tables for TAS. You may need to increase the
value if you write a particularly long or complex selection script.
The QUOTES PER SYMBOL parameter specifies how many quotes you want TAS
to read into memory when performing the selection. The higher this
number, the longer the selection will take.
NOTE : This parameter has a very significant impact on the processing
time that TAS uses for each symbol. It should be set to as low a value
as possible (based on the time periods you use in your indicators) so
that the TAS processing is minimized.
When you register TAS or TAS/PT, you will receive a REGISTRATION CODE
based on your Name. Whatever name you include in the file REGISTER.DOC
will be used to form an encryption code. Use the same form of your name
as sent to me in your REGISTER.DOC file. Place the REGISTRATION CODE
sent to you in the appropriate field.
5.2 Creating TICKER Lists
You can create "ticker lists" with TAS. A "ticker list" is a list of
stock or ticker symbols which you can name as a group. This allows you
to create individualized lists of symbols against which you can run
your TAS scripts. As an example, you could create a ticker list
containing the Dow Jones 30 Industrials, or a list containing only
stocks you hold.
When you choose the TICKER LIST menu, you are asked if you want to
create an new list or modify an existing one.
When you select this menu item, you will be asked if you want to create
a New Ticker List or Modify an Old Ticker List.
If you request a new Ticker List, you will be prompted for the Ticker
List name. Enter only the filename portion, not the .TCK extension. The
file will be created in the \TAS directory.
If you want to modify an old Ticker List, a File Name Selection Screen
will appear which contains the names of all the files in the current
directory ending with ".TCK". Move the cursor or mouse over to the
correct file name and press Enter (or double-click).
The Ticker List screen will then appear with all the ticker symbols
contained in the MSP directories you have configured. Each symbol that
is highlighted in YELLOW has been "selected" for inclusion in the
ticker list. To select or unselect a symbol, move the cursor to the
symbol and hit the SPACE Bar. If the symbol is selected, it becomes
unselected or vice versa.
If you want to SELECT ALL TICKERS, hit the F9 (SELECT ALL) Key. To
UNSELECT ALL TICKERS, hit the F8 (UnSELECT ALL) Key.
Once you have created the ticker list, hit the F3 (Save) Key to save
it. If you do not want to save the list, hit the ESC (Abort) Key.
If you want to run a TAS script against all of your data, create a new
Ticker List called "ALL". Hit the F9 Key to select all symbols. Then
hit the F3 Key to save the list.
5.3 Build or Run Selection
Using the BUILD SELECTION screen of TAS, you can create your own report
containing up to 7 columns of calculated formulas or data values. In
addition, you can use the Condition entry areas (below the Formulas) to
specify which conditions must be satisfied for a ticker to be included in
the report output.
The figure below shows the equivalent of the MetaStock Utility "Rank"
option where the first formula is the Current Price ("C" is the Closing
Price), the second formula is the 26 day Rate of Change (ROC). The
third formula is the 10 day Simple Moving Average of the price. The
fourth is the 10 day Simple Moving Average of "F2", where "F2" is the
26 day ROC. Finally, the last formula F5 is the percentage by which the
Price is above or below the moving average contained in F3.
┌──────────────────────────TAS Selection Creation──────────────────────────┐
│ Column │
│ Enter Formulas Below, e.g. CCI(14) Title │
│ Formula F1 C CURR PRC │
│ Formula F2 ROC(C,26,'%') %ROC/PRC │
│ Formula F3 MOV(C,10,'S') MOV AVG │
│ Formula F4 MOV(F2,10,'S') MA %ROC │
│ Formula F5 (F1/F3-1)*100 %PRC MA │
│ Formula F6 │
│ Formula F7 │
│ │
│ Enter Conditions Below, e.g. F1 > F2 │
│ Condition 1 │
│ Condition 2 │
│ Condition 3 │
│ Condition 4 │
│ Condition 5 │
│ Condition 6 │
│ │
│ │
│ │
└──────────────────────────────────────────────────────────────────────────┘
F1]=Help░░░[F3]=Save░░░[F4]=Run Selection░░[F7]=Formula Builder░░[ESC]=Quit░
You can place any formulas or data value in each of the Formula areas.
If you hit the "F7" key, a list of functions included in TAS will be
shown on the screen and you will be prompted for the parameters of the
function.
The CONDITION entries are used to "select" only those tickers that
match the condition. The conditions are specified in terms of the
formulas given above. In the example above, if you only wanted to see
tickers whose ROC (Formula 'F2') was greater than 50, then you could
set
CONDITION 1 F2 > 50
Also, if you had another condition, for example the current price of
the ticker is greater than $5, you could place that condition as
follows
CONDITION 2 C > 5
and that would now select only tickers whose ROC is greater than 50 and
whose price is greater than $5.
5.4 Editing TAS Scripts
TAS has a built-in text editor which can be used to create and modify
TAS script files. All TAS script files end with the suffix ".TAS".
When you select this menu item, you will be asked if you want to create
a New Script or Modify an Old Script.
If you request a new script, you will be prompted for the script name.
Enter only the filename portion, not the .TAS extension. The file will
be created in the \TAS directory.
If you want to modify an old script, a File Name Selection Screen will
appear which contains the names of all the files in the current
directory ending with ".TAS". Move the cursor or mouse over to the
correct file name and press Enter (or double-click).
The editor screen will then appear with the contents of the file
displayed.
If you need help with the editor, hit the F1 (Help) Key. You will see a
list of editor commands.
One key available in the editor is the F7 (Formula Builder) Key. This
key will bring up a list of Technical Indicator functions and
Pre-defined Data Arrays. If you select one of the functions or arrays,
the subsequent parameters of the function (e.g. MOV "Moving Average"
requires 3 additional parameters) will be prompted. Enter each
parameter. When you are done, the formula and parameters will be placed
into your script file at the location of the cursor when you hit F7.
When you are done with your editing, you can save the file by hitting
the F3 (Save) Key. If you do not want to save the file, hit the ESC
(Abort) Key.
5.5 Running TAS Scripts
If you have created a script (or are using one of the example scripts)
and you want to run it against a specific Ticker List, you should
choose the "RUN TAS Scripts" option from the Main Menu. (You must have
created at least one Ticker List before you can run TAS)
When this option is chosen, you will be asked for the TAS script name
and the Ticker List name. Each choice will be from a list of filenames
ending with the appropriate extension (".TAS" or ".TCK"). Move the
cursor to the correct file name for each choice and hit ENTER.
6 TAS Selection Scripts - Description
TAS Selection reads each ticker in the TICKER LIST from the MSP data file.
It reads the quotes for the file into the pre-defined data arrays up to
the lower of either (1) the number specified in the QUOTES PER SYMBOL (in
the Configure TAS Menu) (2) the number specified in #MAX_QUOTES in the
script file itself, or (3) all the quotes in the file.
Once all the price history has been read into the data arrays, TAS
"executes" the statements in the TAS script file. Once all statements in
the file have been executed, TAS moves on to the next ticker symbol in the
TICKER LIST.
This process continues until all the symbols in the TICKER LIST have been
read or until an error is encountered in the script file.
7 TAS Script Language
The TAS package contains numerous examples of TAS Scripts. You should
print them and look at them while reading the next section. The sample
scripts contain "comments" which explain what the script is doing at each
point of the script.
7.1 Syntax
TAS Script Language (TASSL) syntax is similar to the programming
language "PASCAL". If you are fortunate enough to already know PASCAL,
then the language should be familiar to you. However, if you don't, the
following topics will give an explanation of the language.
In the subsequent discussion, the word "statement" is used. A
"statement" is like a sentence in English. Like a sentence, it is
composed of "words" ("tokens" in computereze). There are only two kinds
of statement in TASSL, the "assignment statement" and the "IF
statement".
A semi-colon (;) is used to tell TAS that the statement you just
entered is done. Every statement must be concluded with a semi-colon.
Also, in the syntax descriptions below, words you must use are in UPPER
CASE, and parts of the statement that are up to you are in lower case.
7.1.1 Building Blocks
The "Building Blocks" of TASSL are the following types of items:
1) "VARIABLES". Variables are where you put values or, in the
case of "pre-defined" variables, where you get them. The
names are anything you choose, but they have to start with a
letter of the alphabet.
2) "ASSIGNMENT STATEMENT". The ASSIGNMENT statement (":=") is
how you can move a value from one place to another.
3) "ARITHMETIC Operators". These are the usual ADD(+), SUBTRACT
(-), MULTIPLY(*) and DIVIDE(/).
4) "FUNCTIONS". A "function" is a built-in Technical Indicator
or "output" function which usually returns a value.
5) IF statements. An "IF" statement is used to test a condition
or value. Once the condition is tested, you can perform
certain actions "if" it is TRUE or "if" it is false.
6) "BEGIN-END Blocks". A "BEGIN-END" block is a way to "group"
several statements into one. For example, the IF statement
only allows you to execute the following "statement".
However, if you use a BEGIN followed by multiple statements,
followed by an END, the whole series of statements from the
BEGIN through the END is considered to be ONE statement. It
is similar to putting parentheses around an arithmetic
expression.
7) "Logical AND". The AND word takes a left-hand side and a
right-hand side. If both are TRUE, the whole is TRUE.
8) "Logical OR". The OR word also has a left and right side. If
either is TRUE, the whole is TRUE.
9) "RELATION Operator". These are how you test the "relation"
between two values. The operators are:
EQUAL =
GREATER THAN >
GREATER THAN OR EQUAL >=
LESS THAN <
LESS THAN OR EQUAL <=
NOT EQUAL <>
10) Comments. These are used to "document" the TASSL script.
They perform no function, but only help to understand what
is going on in the general area of the script. They are good
to use and should be included in the script to make it
easier to understand.
7.1.2 Variables
The concept of a "variable" is difficult to communicate to anyone
who hasn't programmed before. Loosely speaking, it is a name given
to a "place" to put a "value". Think of it as a "name for a value".
Except for "pre-defined" variables (see below) you can make up the
names for the variables in your script.
A variable name must start with an alphabetic letter, contain only
letters, numbers and underscores ("_"). Some valid names are:
my_stuff, my_122999, my999, m9, M32_togo, Beethoven, etc
Generally, you first use variables in "assignment statements", that
is, you first "put" something into them. Subsequently, you can use
them as values passed to functions or in an IF statement.
7.1.3 TAS Variable Types
7.1.3.1 "String" Variables -
These are variables to hold text information, like "IBM", or
"THIS IS A STICK-UP".
7.1.3.2 "Numeric" Variables
These are variables that hold numbers, like 32, or -75.69, or
10000034.
7.1.3.3 "Numeric Array" Variables
These are variables that hold many numbers in an "array". All of
the numbers in the array have the same variable name; however,
you cannot "look" at them all at once.
You must pick out one of the numbers of the array by specifying
its location in the array. The pre-defined data arrays, like H,
L, C, V (for High Price, Low Price, Closing Price and Volume) are
examples of arrays.
If you want to refer to a closing price 10 days ago, you need to
say C[-10]. Each time you refer to an "element" of an array, you
must provide the "subscript" in square brackets, e.g. [-10],
which means "subscript minus ten".
You can define your own variable array by "declaring" it (prior
to first using it) as follows:
variable_name : ARRAY;
where 'variable_name' is the name by which you want to refer to
the array.
7.1.4 Assignment Statement
The Assignment Statement is used to set the contents of a variable
to the result of an "expression". An "expression" is another of
those computereze terms, but it means sequence of mathematical
operations and/or the result of a "function".
It might help to give some examples of assignment operations:
a := b + 3 / 4;
The ":=" (colon-equal) is the operator that says "assign to". So,
reading the above assignment, in English, it says "add the contents
of variable 'b' to the result of dividing 3 by 4. Place this result
in variable 'a'". If variable 'b' contained 6 when this statement
was encountered, then variable 'a' would contain 6.75 (6 + 3/4).
Another example is:
a := (c[-1] + c[0]) / 2;
In this example, the array 'c' is pre-defined as the "closing price
array". So, the statement is adding the closing price yesterday
(c[-1]) to the closing price today (c[0]). It is then dividing the
total of this addition by 2 and placing the result in variable 'a'.
Note the use of the parentheses to "group" the addition so that it
would be done before the division by 2. If there were no
parentheses, the result would have been considerably different.
Instead, it would have divided today's closing price by 2, added it
to yesterday's closing price, and placed the result in 'a'.
Another example of an assignment is the result of a "function" call.
All Technical Indicators available in TAS are created by making a
"function" call. In other words, the Technical Indicator is referred
to by its name (the "function"). So, for example,
a := mov(c,21,'E');
calculates the 21 day exponential moving average ("mov" function) of
the closing price array. If variable 'a' has been declared to be an
ARRAY prior to this point, then 'a' contains all the moving average
"points". If 'a' has not been declared as an ARRAY, then 'a' will
contain the value of the moving average AT THE LAST POINT of the
range, i.e., today's value.
7.1.5 Arithmetic Operators
Arithmetic Operators are addition (plus sign '+'), subtraction
(minus sign '-'), multiplication (asterisk '*') and division (slash
'/'). When you write an arithmetic expression, you should use
parentheses to guarantee the order in which the operations are
performed. In general, division and multiplication are performed
first, then addition and subtraction.
7.1.6 Functions
A "function" is a reference to a "built-in" Technical Indicator
function (like "MOV(...)"), an output function (like WRITE or
WRITELN), or an array manipulation function (like DIVBY). See the
individual descriptions of each function in the MSP User's Guide for
a more complete definition of the meaning of the various Technical
Indicators.
7.1.7 IF Statements
The IF statement is the most powerful scanning feature of TAS. It
enables you to create complex relationships between indicators based
on their relationship with other indicators and values.
An IF statement is written as follows:
IF expression THEN
statement to execute if the 'expression' is true
ELSE
statement to execute if the 'expression' is false;
The ELSE part of the IF statement is optional, but sometimes it is
convenient to make a two way decision about something. You could
alternatively say:
IF expression THEN
statement to execute if the 'expression' is true;
The TAS language does not require you to include the word THEN after
the IF part of the statement. You must terminate each IF statement
with a semi-colon. Note, however, that IF statements containing an
ELSE part are terminated __after__ the ELSE part. For example,
IF a > b THEN
WRITELN('a is greater than b, hurray!')
ELSE
WRITELN('a is not greater than b, sorry.');
Note how there is a semi-colon on the last line, but not after the
first WRITELN. However, if you wanted to print a message only if "a"
is greater than "b", then you would say
IF a > b THEN
WRITELN('a is greater than b, hurray!');
Note the semi-colon after the last line.
7.1.8 BEGIN..END Statement
Suppose you want to do more than one thing if the condition "a is
greater than b" is true. In that case, you would need to use a BEGIN
.. END block. A "BEGIN..END" block "groups" all statements between
the BEGIN and the END so that the entire "group" is treated as if it
were one statement.
This is useful in the case of the IF statement, because the action
to be taken following the THEN or ELSE part of the IF can only be
one statement. But if you use the BEGIN..END block to group several
statements, the entire block is treated as a "single" statement.
Think of BEGIN..END blocks in the same way you would think of
parenthesized arithmetic expressions. You use parentheses to "group"
some operations so that they are treated as a group.
An example of the use of the BEGIN..END block in an IF statement is
shown below:
IF a > b THEN
BEGIN
a := a - 1;
b := mov(c,21,'E');
WRITELN('New values for a and b are: ',a,' ',b);
END;
All three statements following the BEGIN will be executed (acted
upon) if the value of "a" is greater than the value of "b". If you
had left out the BEGIN..END section, only the first statement ("a :=
a - 1") would have been done if "a > b" was true. The following two
statements would have ALWAYS been done, since they were not part of
the IF.
7.1.9 Profit Test Statements
Profit Test Statements are used to:
1) Define which Technical Indicators are to be computed.
2) Define BUY conditions
3) Define SELL conditions
4) Define STOP conditions
The statments used to describe the situations above are described in
the next 4 sections.
7.1.9.1 PLOT statement: Define Technical Indicators
The PLOT statement is used to create the formulas or indicators which
will be used in the subsequent profit test. The PLOT statement is
executed once per ticker symbol, and must be placed prior to any of
the BUY/SELL/STOP WHEN conditions.
The format of the PLOT statment is:
PLOT stmt;
where 'stmt' can be a single statement or a BEGIN..END block. For
example, if your profit test is to test the Commodity Channel Index
(CCI) for 14 days, you could say:
CCI_ARRAY : ARRAY; { Define the cci array}
PLOT CCI_ARRAY := CCI(14);
In the example, only one indicator is computed, so there was no need
to use the BEGIN..END block. Suppose, however, that we want to
incorporate Wilder's RSI in the profit test as well. Then we would
say:
CCI_ARRAY : ARRAY; { Define the cci array}
RSI_ARRAY : ARRAY; { Define the rsi array}
PLOT BEGIN
CCI_ARRAY := CCI(14);
RSI_ARRAY := RSI(14);
END; { of PLOT statement}
7.1.9.2 BUY WHEN - Define BUY Conditions
The BUY WHEN condition causes the profit tester to 'buy' the stock if
the condition is true.
BUY WHEN expression;
where 'expression' can be any combination of logical or relational
operators.
For example, using the last PLOT statement in the previous example, we
will issue a BUY signal when the CCI rises above -100 and the RSI is
less than 40:
BUY WHEN cci_array[-1] < -100
AND cci_array[0] > -100
AND rsi_array < 40;
7.1.9.3 SELL WHEN - Define SELL Conditions
The SELL WHEN condition causes the profit tester to 'sell' the stock
if the condition is true.
SELL WHEN expression;
where 'expression' can be any combination of logical or relational
operators.
For example, using the last PLOT statement in the previous example, we
will issue a SELL signal when the CCI drops below 100 and the RSI is
greater than 60:
SELL WHEN cci_array[-1] > 100
AND cci_array[0] < 100
AND rsi_array > 60;
7.1.9.4 STOP (LONG or SHORT) Condition
The STOP LONG and STOP SHORT statements close a "long" position or a
"short" position, respectively, but either selling or buying to cover
an open position.
To close out a long position (by selling), the statement is:
STOP LONG WHEN expression;
where 'expression' can be any combination of logical or relational
operators.
To close out a short position (by buying), the statement is:
STOP SHORT WHEN expression;
where 'expression' can be any combination of logical or relational
operators.
Adding a long stop to the example built in the prior sections, we
could say that we want to issue a stop if, after having gone long, the
CCI drops below -100 again. In that case, we could say:
STOP LONG WHEN cci_array < -100;
7.1.10 Logical Operators
You can combine relations by using the words "AND" and "OR". They
have the same sense as in English. Whenever you use AND and OR, you
can use parentheses to group your relations to be sure they are
computed the way you want them to be understood. For example:
IF a > b AND b = 1 THEN
WRITELN('a is greater than b and b is equal to 1');
This example compares "a" to "b". If "a" is greater than "b", then
it compares "b" to the number 1. If "b" is equal to 1, then the
message
a is greater than b and b is equal to 1
will be printed. If either of the "relations" (a in "relation" to b
AND b in "relation" to 1) is not true, then the WRITELN will not be
done.
On the other hand, suppose we want to print the message if either of
the conditions is true. Then we would say:
IF a > b OR b = 1 THEN
WRITELN('a is greater than b OR b is equal to 1');
In this case, it would print the message if "a" were greater than
"b" or if "b" were equal to 1.
7.1.11 Relational Operators
Relational Operators describe a "relationship" between the
expression on the left of the operator and the expression on the
right of the operator. For example, "a > b". 'a' is on the left
side, 'b' is on the right side, and the operator is '>' which means
"greater than".
The operators you can use in your TASSL script are shown on the
right below:
EQUAL =
GREATER THAN >
GREATER THAN OR EQUAL >=
LESS THAN <
LESS THAN OR EQUAL <=
NOT EQUAL <>
7.1.12 Comments
Comments are surrounded on both sides by "curly braces". These are
the characters at the right of your keyboard. They look like this:
{ - Left "curly brace"
} - Right "curly brace"
You can place these "curly braces" around any thing in your script
file that you do not want TAS see. It is only for your eyes and the
eyes of other humans.
7.2 Pre-Defined Variables
Predefined Variables are variables that are "filled in" when each MSP
TICKER is processed or at specific times during the processing of
ticker files.
TICKER The 'ticker' symbol, e.g., AXP
FULLNAME The 'full name', e.g., AMERICAN EXPRESS
QUOTE_COUNT The number of quotes in the file
FIRST_TICKER Variable, which, if equal to 1 (one), indicates
this ticker is the first to be processed.
LAST_TICKER Variable, which, if equal to 1 (one), indicates
this ticker is the last to be processed.
DATE The date of the latest quote in the file
in the format YYMMDD.
O The OPEN "data array"
H The HIGH "data array"
L The LOW "data array"
C The CLOSE "data array"
V The VOLUME "data array"
OI The OPEN INTEREST "data array"
P The "last computed" array. For example,
X := MOV(C,30,'E')
places the last day's 30day EMA in 'X' and
the entire EMA array is in 'P' until another
function is called.
PLOT_PHASE Variable which is set to 1 when the Profit Test
Script is entered for the first time for a
ticker. (TAS/PT only).
TEST_PHASE Variable which is set to 1 when the Profit Test
Script is entered for the EACH quote for a
ticker. (TAS/PT only).
END_PHASE Variable which is set to 1 when the Profit Test
Script is entered for the last quote for a
ticker. (TAS/PT only).
7.3 Pre-defined Functions
TAS functions which are also available in MetaStock have the same names
and (nearly the same) parameters as those documented in the MSP Custom
Formulas Section of the MSP "User's Manual".
Functions which are unique to TAS (not shared by MetaStock) are
described in detail in this document. The MetaStock functions are only
summarized. Please refer to the Metastock documentation for a complete
description of the functions and their parameters.
In some instances, the parameter to an MetaStock named function has to
have single quotes around it. This is the case with any function that
passes a single character as a parameter, such as the last parameter in
the "mov" (Moving Average) function.
7.3.1 MSP Technical Indicators
ad() Accumulation/Distribution Array
adx(p) Average Directional Movement
adxr(p) Average Directional Movement Rating
add(a,b) Add each element of array "a"
to the corresponding element of
array "b".
cci(p) Commodity Channel Index Array
p = number of periods
co() Chaikin's Oscillator Array
cum(a) Cumulative Sum of Array "a"
div(a,b) Divide each element of array "a"
by an element of array "b".
dx(p) Directional Movement Index
macd() Moving Average Convergence/
Divergence
mdi(p) Minus Directional Movement
Indicator
mo(p) Momentum Array
p = number of periods
mov(d,p,t) Moving Average Array
d = Data Array
p = number of periods
t = Moving Average Type
'E' - Exponential
'S' - Simple
'W' - Weighted
mul(a,b) Multiply each element of array "a"
by the corresponding element of
array "b".
neg(a) Negative of Array "a"
nvi() Negative Volume Indicator
obv() On Balance Volume
pdi(p) Positive Directional Movement
Indicator
pvi() Positive Volume Indicator
rsi(p) Wilder's Relative Strength Indicator
p = number of periods
roc(d,p,r) Rate Of Change Array
d = Data Array
p = number of periods
r = ROC Type
'%' - percentage ROC
'$' - Unit ROC
stoch(p,s) Stochastic Oscillator
p = number of periods
s = k slowing periods
sub(a,b) Subtract each element of array "b"
from the corresponding element of
array "a".
vol(pm,pr) Volatility Indicator. This is the 'pr' day Rate Of
Change Oscillator of a 'pm' day exponential Moving
Average of the difference between each day's high and
low price.
7.3.2 TAS Functions
divby(a,x) Divide each element of array "a" by the value of "x".
In this case, "x" is a single number.
mulby(a,x) - Multiply each element of array "a" by the value of
"x". In this case, "x" is a single number.
int(x) Turns the number "x" into the nearest "integer". An
integer is a number without a fractional part (the
part after the decimal). The maximum number that you
can turn into an integer is 32,767.
isect(a,b) Find the latest intersecting point of the two arrays
"a" and "b". Returns the number of days since the two
arrays intersected or -1 (negative one) if they have
never intersected.
NOTE:
Since the graph of the two arrays actually crosses
BETWEEN two days, the value returned will be the later
day AFTER the crossing. For example, if the arrays
crossed between yesterday and today, the value
returned will be zero. If they crossed between two
days ago and yesterday, the value returned will be 1,
and so forth.
over(a,b) If array "a" is "over" array "b", this function
returns the number of days since array "a" crossed
above array "b". See the note under the "isect"
function.
linreg(a,s,e) Create a linear regression line using "least-squares"
method to find the mathematical average of the values
in the array "a" starting at entry "s" and ending at
entry "e". If "s" is zero, it refers to the first
value in the array. If "e" is zero, it refers to the
last value in the array. Positive values for "s" or
"e" refer to the appropriate array entries (counting
from 0).
A negative number in the "s" or "e" index is
subtracted from the total number of entries in the
array to get the appropriate positive array index.
For example,
x : array;
x := linreg(c,-50,-10);
will find the line passing most closely through the
closing prices from 50 days before the last day in the
file to 10 days before the last day in the file.
slope(a) will return the mathematical "slope" of the line whose
points are contained in array "a". This array must
have been created with the "linreg" function.
corrcoef() returns the "correlation coefficient" of the last
linear regression performed. This value ranges from
-100 to +100. If the data points match the points in
the linear regression approximation, the correlation
coefficient will be 100. If the points show no
correlation with the approximation, the correlation
coefficient will be zero.
angle(a) returns the angle in degrees of the line described by
the array 'a'.
7.3.3 TAS Profit Tester Functions
The Profit Tester feature of TAS uses the following functions to
indicate the buy/sell transactions controlled by a Profit Testing
script. Refer to the script 'RSIPT.TAS' for an example of the use of
the Profit Test functions.
pt_init(m,t) Initializes the Profit Test Feature. Clears all
counters to zero, prints the heading for the report.
The first parameter, 'm', is the amount of Money to
start the test with. The second parameter, 't', is the
type of test, 'L' = Long, 'S' = Short, 'B' = Both Long
and Short. This function should be called when the
variable PLOT_PHASE is true (1).
pt_buy() Profit Tester - Buy the stock at the current closing
price if not already held. If testing Short positions,
buy to 'cover' the short sale.
pt_sell() Profit Tester - Sell the stock at the current closing
price if it has been bought. If testing Short
positions, sell the stock short.
pt_stop(t) Profit Tester - Issue either a Long Stop or a Short
Stop. The parameter 't' is either 'L' for a Long Stop,
or 'S' for a Short Stop.
pt_total() Profit Tester - Closes out all open positions,
produces a Summary Report for the equity. This
function should be called when the variable END_PHASE
is true.
7.3.4 Output Functions
There are two output functions, WRITE and WRITELN. The WRITELN
function is identical to the WRITE function, except that WRITELN
causes a NEW LINE to be added at the end of the last field.
The parameters to WRITE (and WRITELN) are either text strings, like
'this is a text string', surrounded by single quotes ('), or
"variable values". A variable value is a value that you have
assigned to a name by use of a formula or constant setting. There
are "pre-defined" variables, such as H, L, C, V, O, TICKER,
FULLNAME. These pre-defined variables are "filled in" when TAS reads
the data values for each symbol.
You can control the formatting of your output to some extent by
using the characters sequence "\t" (backslash tee) in your text
string. This will place a "tab" character in the output. TAS places
"tab stops" every 4 columns of the output line.
In addition, the sizes of the two types of "numbers", are constant.
If you are printing an INTEGER value, it is five characters wide,
left-justified. If you are printing a number with a decimal point,
it is eight characters wide (99999.999). This will allow you to line
up the output with column headings.
7.3.5 Column Headings
For an example of controlling the printing of 'headings' in your TAS
output, go to the section describing the pre-defined variable
FIRST_TICKER. Using this variable, you can determine when to print a
heading initially in your report.
In addition, since all variables are initially set to zero before
the first TICKER file is processed, you can use a variable to
accumulate a "line count". You can test this variable and generate a
new heading each time it is greater than the number of lines on your
page (e.g. 66). An example of how to place a heading on each page of
the report follows:
IF FIRST_TICKER OR (LINE_COUNT > 65) THEN
BEGIN
LINE_COUNT := 0;
WRITELN('YOUR REPORT HEADING WOULD GO HERE');
END;
Then, each time you wrote a line in your script you would execute
the statement: LINE_COUNT := LINE_COUNT + 1;
7.4 Putting Them Together
If the script has the statements:
todays_ma := mov(c,21,'E');
diff := c[0] - todays_ma;
if diff > 0 then
writeln(TICKER, ' IS ABOVE 21 DAY EMA BY ',diff);
else
writeln(TICKER, ' IS BELOW 21 DAY EMA BY ',diff);
The script will print out the ticker name followed by the message
indicating whether the latest close is above or below the 21 day EMA,
and by how much.
In this particular example, let's take a closer look at what is going
on. In the first line,
todays_ma := mov(c,21,'E');
we are computing the 21 day Exponential Moving Average of the Closing
Price Array. Once computed, we are assigning the latest value of this
moving average to the "variable" named 'todays_ma'. You could call it
anything you want, but giving it a name that reminds you of what it
contains is useful.
If you wanted to keep the 21-day EMA in its own array. You could
declare the variable as follows (before using it the first time):
big_ma_array : ARRAY;
This tells TAS that "big_ma_array" is an array of values, not just one
value. So, if you now said:
big_ma_array := mov(c,21,'E');
the contents of big_ma_array would be ALL of the Moving Average values
up to the latest day. To refer to the value of the 21 day EMA
yesterday, we would write "big_ma_array[-1]" where the "[-1]" refers to
the contents of the array "-1" days from now (in other words, one day
ago). If you wanted to refer to the 21 day EMA 10 days ago, it would be
"big_ma_array[-10]". If you wanted to refer to the latest day's 21 day
EMA, it would be "big_ma_array[0]" (zero days ago).
The next statement in the example is:
diff := c[0] - todays_ma;
which assigns to the variable "diff" the value of the latest closing
price, "c[0]", minus the latest 21 day EMA as computed and assigned to
the variable "todays_ma" in the previous statement.
7.5 Pre-defined Data Arrays
The Data Array field is one of the fields within
the quote for a symbol. The names of the fields are:
Name Description
H High Price
L Low Price
C Closing Price
V Volume
OI Open Interest
O Open
7.6 Pre-defined Values
7.6.1 TICKER
This is the TICKER name, left justified and padded with blanks to be
8 characters long.
7.6.2 FULLNAME
This is the long name of the symbol, left justified and padded with
blanks to be 16 characters long.
7.6.3 QUOTE_COUNT
This is a pre-defined value which contains the total number of
quotes in the current data file.
7.6.4 DATE
The DATE variable is set to the date of the LAST quote in the file.
It is a 'string' variable in the format YYMMDD. For example, if the
last quote in the MSP ticker file is for Jan 4, 1991, the value of
DATE will be '910104'.
7.6.5 FIRST_TICKER
This variable is set by TAS. It has a value of 1 (one) if the
current ticker being processed is the first ticker for this script.
This variable can be used to control the printing of headings for
your script output. See the example below:
if first_ticker then {write a heading line next }
writeln('TICKER\t\tHIGH\tLOW\tCLOSE\tVOLUME\tDATE');
{ now, for all tickers, write the high,low,close,volume and date }
vol := int(v[0]); { get volume in integer format }
writeln(ticker,'\t',h[0],'\t',l[0],'\t',c[0],'\t',vol,'\t',date);
The above example will create a report that looks like the
following:
TICKER HIGH LOW CLOSE VOLUME DATE
ABX 21.625 21.125 21.625 2315 910103
AAPL 44.250 43.000 43.000 13409 910103
ARIX 0.625 0.531 0.562 33 910103
CMNT 2.500 2.375 2.500 191 910103
GR 38.500 37.750 38.000 517 910103
SWZ 12.000 11.875 11.875 57 910103
LA 13.875 13.375 13.750 2696 910103
PCG 25.125 24.750 24.875 5592 910103
TX 59.375 58.250 58.625 3899 910103
UAL 113.125 111.250 112.000 2354 910103
MXTR 5.250 5.000 5.062 2783 910103
BP% 8.000 7.625 7.625 658 910103
7.7 TAS "POUND" (#) Commands
TAS "POUND" commands are used to control special script processing.
They must begin with a "pound sign" ('#') in the first column of the
line, and they must be completed on the same line.
7.7.1 OUTPUT_FILE command
You can direct the output of a script to a file by placing an
#OUTPUT_FILE command in the script file. The #OUTPUT_FILE command
must start in the first column of the line. It should be followed by
the output file name surrounded by single quotes.
For example,
#OUTPUT_FILE 'select.lst'
would place the output text of the script into the file
'select.lst'.
7.7.2 MAX_QUOTES Command
You can use the #MAX_QUOTES command to limit the number of quotes
read into a script. This value will "override" the MAXIMUM QUOTES
you specified in the TAS Configuration Menu, for the script in which
it is contained only.
The format of the #MAX_QUOTES command is:
#MAX_QUOTES nnn
where "nnn" is the number of quotes to read into TAS when this
script is processed.
7.7.3 SCAN_DATE Command
You can use the #SCAN_DATE command to force TAS to not process
quotes after the date given in the command. This enables you to go
back to a prior date and look at what the TAS script would have done
on that date.
The format of the #SCAN_DATE command is:
#SCAN_DATE 'yymmdd'
where yymmdd is the year, month, and day of the last quote to be
read into TAS before the script is run. Note that you must use
single quotes around the date given.
7.7.4 PROFIT_TEST Command
The #PROFIT_TEST command informs TAS of the type of profit test you
want to run, whether you want to test "LONG" or "SHORT" positions,
and the amount of "money" you want your position to start with. This
command must be placed in the front of the TAS script, prior to any
statements which do not begin with a # sign.
TAS runs the profit test in two phases. The first phase, called 'PLOT
PHASE' is when the script should compute the arrays to be tested during
the next phase. This next phase is the 'TEST PHASE'. This phase is
entered for the data points of the ticker file. After all data points
have been processed, the 'END PHASE' indicator is set. Each 'phase' of
the Profit Test process is indicated by a variable being equal to 1.
The two phases are analogous to the steps you might run in Metastock
to do the Profitability Test. First, you would plot an indicator,
moving average, or custom formula. This is similar to the 'PLOT
PHASE' in TAS. Next, you would run the Profit Tester specifying your
Buy/Sell conditions. Metastock then applies your Buy/Sell signals to
each plotted point on the graph, proceeding left to right until it
reaches the last day loaded. This is the 'TEST PHASE' in TAS.
When the TEST PHASE is entered with the last day of the ticker file,
a variable, called 'END_PHASE' is set to 1. Testing this variable
will allow you to print out the results for the Profit Test.
For each ticker, the script is entered once for the PLOT Phase, and
then as many times as there are data points for the TEST Phase.
The format of the #PROFIT_TEST command is:
#PROFIT_TEST type money
where 'type' is either LONG or SHORT (for a "long" position test or
a "short" position test) and "money" is the amount of money with
which to start the test for each symbol.
For example, if you plotted a 21 day EMA, and you were testing the
EMA greater than the closing price, it would not make sense to call
the TEST Phase earlier than plot entry 21. So, you would say
8 TAS Script Examples
Included with the TAS package are several sample .TAS script files. Check
your directory after you install TAS to see the samples included.
8.1 New High/New Low Example
The following script is contained in file "NHNL.TAS".
8.1.1 Script Contents
{ NHNL.TAS-
This script example will show the 52 week high and low for each
ticker. If the current day's high is equal to the highest high
or the current low is equal to the lowest low, then we have a
probable new high or new low. It might also be the case that today's
high or low is just equal to the previous high or low.
Just to make the script slightly more interesting, we will also
compute the "percentage off from high", a frequently used metric
seen in financial tables.
}
if first_ticker then
begin
writeln(' - CURRENT - - 52 WEEK - OFF');
writeln('TICKER HIGH LOW HIGH LOW HIGH');
end;
high_value := HHV(h,52*5); { compute high over 52 weeks }
low_value := LLV(L,52*5); { compute low over 52 weeks }
off_high_value := ((high_value - c) / high_value) * 100;
write(TICKER,' ',h,' ',l,' ',high_value,' ',low_value,
'\t',INT(off_high_value),'%');
if (high_value <= h) then { today's high is new high }
write(' New High ');
if (low_value >= l) then { today's low is new low }
write(' New Low ');
write('\n'); { end the line with a 'newline'}
8.1.2 Script Output
- CURRENT - - 52 WEEK - OFF
TICKER HIGH LOW HIGH LOW HIGH
ABX 21.875 21.375 24.750 15.875 13%
AAPL 28.000 26.000 50.375 26.000 47% New Low
ARIX 1.062 0.938 5.625 0.875 81%
BP% 12.500 11.125 14.500 6.000 17%
CMNT 2.312 2.188 3.500 2.063 33%
GR 32.125 31.875 57.500 29.500 44%
SWZ 12.125 11.750 17.500 10.875 32%
LA 11.625 10.375 50.375 9.750 77%
MXTR 5.625 5.250 16.500 5.250 66% New Low
PCG 22.375 22.000 23.500 18.750 4%
TX 61.625 60.125 68.500 49.875 12%
UAL 110.000 99.000 286.750 87.250 64%
8.2 TICKER Symbol Processing
The following example shows how you could create a special script to
notify you when certain stocks had reached prices you had set. This
script is in "LIMIT.TAS".
8.2.1 Script Contents
{ limit.tas
This is an example of using a TAS script to watch your
stocks.
It checks the ticker symbol against one of several
which you might (and I do) own. If the current close
(shown as 'c[0]' is greater than the limit for profit
or less than the stop loss, a message is generated.
}
stop_loss := 0;
sell_profit := 0;
if ticker = 'aapl' then
if c > 47 then
sell_profit := 1;
else
if c < 41 then
stop_loss := 1;
if ticker = 'gr' then
if c > 43 then
sell_profit := 1;
else
if c < 38 then
stop_loss := 1;
if ticker = 'la' then
if c > 27 then
sell_profit := 1;
else
if c < 10 then
stop_loss := 1;
if stop_loss = 1 then
writeln(ticker, ' has reached your STOP LOSS limit. SELL');
if sell_profit = 1 then
writeln(ticker, ' has reached your Profit target. SELL');
8.3 Directional Movement Example
The following script is contained in file "DM.TAS".
NOTE : This script will only work with the REGISTERED VERSION of TAS.
8.3.1 Script Contents
{ DM.TAS
Wilder's Directional Movement Trading Example
This script will indicate
a BUY signal
if the +DI(14) crosses above -DI(14) and ADXR > 25
a SELL signal
if the -DI(14) crosses above +DI(14) and ADXR > 25
}
pdi_array : array; { declare the +DI (Positive Directional Movement
array}
mdi_array : array; { declare the -DI (Negative Directional Movement
array}
pdi_array := pdi(14); { calculate +DI}
mdi_array := mdi(14); { calculate -DI}
adxr_14 := adxr(14);
if (adxr_14 > 25) then { AVG DX Rate of Change > 25 }
begin
if (over(pdi_array,mdi_array) = 0) then
writeln(TICKER,' +DI crossed upward over -DI *** BUY SIGNAL ***')
else
if (over(mdi_array,pdi_array) = 0) then
writeln(TICKER,' +DI crossed downward over -DI *** SELL SIGNAL***')
else
begin
write(TICKER);
write(' +DI ',pdi_array[-1],' --> ',pdi_array[0]);
write(' -DI ',mdi_array[-1],' --> ',mdi_array[0]);
writeln(' ADXR is ',adxr_14);
end;
end;
8.3.2 Script Output
AAPL +DI 33.000 --> 32.000 -DI 17.000 --> 16.000 ADXR is 39.000
ARIX +DI 17.000 --> 23.000 -DI 16.000 --> 14.000 ADXR is 28.000
GR +DI 26.000 --> 28.000 -DI 34.000 --> 29.000 ADXR is 30.000
LA +DI crossed downward over -DI *** SELL SIGNAL ***
UAL +DI 44.000 --> 39.000 -DI 14.000 --> 22.000 ADXR is 36.000
VCITX +DI 50.000 --> 50.000 -DI 50.000 --> 50.000 ADXR is 33.000
8.4 Modified "Binary Wave"
The file "SELECT.TAS" contains a rather lengthy script which contains
the logic for computing a 6 point "binary wave". The first 4 "points"
of the wave are those described in the "MetaStock User's Manual" in
Chapter 7, section 7.7.2 "Example Binary Waves".
The final 2 points of the "binary wave" are included to show how you
can extend the original example to compute additional indicators
(Chaikin's Oscillator and Commodity Channel Index) which are used to
further refine the selection.
Since the file is large, it is not included in this documentation, but
the file is included in the TAS package.
NOTE : This script may only work with the REGISTERED VERSION of TAS.
8.5 Profit Test Example Using RSI(14)
The TAS Script file 'RSIPT.TAS' shows a Profit Test using the 14-day
RSI. It serves as an example of the kind of profit testing available
with TAS/PT.
NOTE : This script may only work with the REGISTERED VERSION of TAS/PT.
8.5.1 Script Contents (RSIPT.TAS)
{
RSIPT.TAS
RSI PROFIT TEST SCRIPT EXAMPLE
This script will signal a SELL when the
RSI(14) crosses under 'rsi_upper' and a BUY when
RSI(14) crosses above 'rsi_lower'.
}
#PROFIT_TEST LONG 1000 { long positions with $1000}
#MAX_QUOTES 300 { only read in 300 quotes }
#OUTPUT_FILE 'RSIPT.LST' { assign output listing to rsipt.lst}
RSI_VALUES : ARRAY; { array containing plotted points }
RSI_UPPER := 75; { Upper range of RSI - point to SELL
Change this if
you want to test different value}
RSI_LOWER := 50; { Lower range of RSI - point to BUY
Change this if
you want to test different value}
PLOT BEGIN { This begins the "plot" of the RSI }
RSI_VALUES := RSI(14); { COMPUTE THE RSI(14) PLOT }
END;
BUY WHEN RSI_VALUES[-1] < RSI_LOWER AND RSI_VALUES > RSI_LOWER;
SELL WHEN RSI_VALUES[-1] > RSI_UPPER AND RSI_VALUES < RSI_UPPER;
8.5.2 Script Output
Technical Analysis Scanner (TAS) Profit Test
Wed Jan 23 16:04:23 1991
3COM (COMS) From 02/21/90 To 01/22/91
Initial Cash $ 1000.00. (Long Positions Only)
Trade Total
Date Action Shrs Price Points Cash Profit Profit
------- -------- ---- -------- ------ ------- ------- -------
04/06/90 Buy 75 13.250 0.000 6.25 0.00 0.00
06/18/90 Sell 75 16.375 3.125 1234.38 234.38 234.38
11/02/90 Buy 170 7.250 0.000 1.88 0.00 234.38
Summary for COMS
Long Short Total
---------------------------------------------------------------
Trades 2 0 2
Profitable 1 ( 50.00%) 0 ( 0.00%) 1 ( 50.00%)
Stops 0 0 0
Profit $ 234.38 0.00 234.38
There is a Long Position which is still open.
If it were liquidated at today's price of 6.375,
the profit would be $ 85.62
Technical Analysis Scanner (TAS) Profit Test
Wed Jan 23 16:04:30 1991
APPLE (AAPL) From 01/18/90 To 01/22/91
Initial Cash $ 1000.00. (Long Positions Only)
Trade Total
Date Action Shrs Price Points Cash Profit Profit
------- -------- ---- -------- ------ ------- ------- -------
03/01/90 Buy 29 34.250 0.000 6.75 0.00 0.00
03/20/90 Sell 29 41.375 7.125 1206.62 206.62 206.62
05/07/90 Buy 29 41.500 0.000 3.12 0.00 206.62
12/10/90 Sell 29 41.750 0.250 1213.88 7.25 213.88
Summary for AAPL
Long Short Total
---------------------------------------------------------------
Trades 2 0 2
Profitable 2 (100.00%) 0 ( 0.00%) 2 (100.00%)
Stops 0 0 0
Profit $ 213.88 0.00 213.88
Summary for ALL SYMBOLS
Long Short Total
---------------------------------------------------------------
Trades 4 0 4
Profitable 3 ( 75.00%) 0 ( 0.00%) 3 ( 75.00%)
Stops 0 0 0
Profit $ 448.25 0.00 448.25
Profit (Including Open Positions) $ 299.50
9 TAS Change History
9.1 Version 1.4
- Set size of INTEGER output to 5 characters, left-justified
- Set size of REAL numbers to 8 characters, left-justified
- Fixed problems with complex function nesting
- Round values of Directional Movement Indicator suite to integer
values
- Fixed problem with declared arrays being reused for intermediate
temporary arrays.
9.2 Version 1.5 - Jan 11, 1991
- Added OBV(), PVI(), NVI(), NEG(), CUM() functions
- Fixed problem which occurred if a WRITE was called with a
parameter which is a function returning an array. Always
printed the address of the array rather than the last entry
of the array.
- Fixed zero divide problem which occurred sometimes in ROC()
function.
9.3 Version 1.6 - Jan 14, 1991
- Added #OUTPUT_FILE command to allow writing script output to
a file.
- Added #MAX_QUOTES command so that the Maximum Number of
Quotes specified in the Configuration Menu can be over-ridden
for individual scripts.
- Fixed inconsistencies in some of the 'tab' formatting between
the trial version and registered version.
9.4 Version 1.7 - Jan 17, 1991
- Added #SCAN_DATE command to stop loading data after a
specific date.
- Added LINREG() 'Linear Regression' function, SLOPE() function
and CORRCOEF() function.
9.5 Version 2.0 - Jan 19, 1991
- Added #PROFIT_TEST command. This included variables
PLOT_PHASE, TEST_PHASE, END_PHASE and LAST_TICKER. Added
Profit Test functions PT_INIT(), PT_BUY(), PT_SELL(),
PT_STOP(), and PT_TOTAL().
- Corrected errors in beginning of Exponential Moving Average
and MACD array calculation.
- Added Functions ANGLE() and VOL()
9.6 Version 2.1 - Jan 26, 1991
- Fixed several problems with the TAS Script Editor. Added the
ability to 'split' a line by hitting ENTER when in INSERT
mode.
9.7 Version 2.2 - Feb 2, 1991
- Reworked PROFIT TEST features for ease of use. Added BUY/SELL
WHEN, PLOT BEGIN...END; Removed requirement for directly
calling the PT_xxxx functions.
- Simplified expression syntax by making AND and OR operators
lower precedence than Relational Operators. This removes
nearly all requirement for parentheses in statements.
- Allow '=' (equal sign) to be used for Assignment.
- Remove requirement to follow IF statement with THEN.
- Added CHARTPRO support.
9.8 Version 2.3 - Feb 6, 1991
- Fixed bug in Profit Test which miscomputed the last day's
closing price if the position was "open" at the end of the
run.
- Made change to Wilder's RSI calculation to bring it closer to
the Metastock calculation.
- Removed "beep" at end of TAS Run. Changed message to show
successful run.
9.9 Version 2.4 - Feb 12, 1991
- Added "Build or Run Selection" screen.
- Modified expression analyzer to allow mixing arrays and real
values in an expression.
9.10 Version 2.5 - Feb 15, 1991
- Added ability to include the heading in the PRINT function of
the SELECTION RUN screen. Also added option to append to the
file or replace it when printing.
- TICKER LIST menu now shows tickers sorted in alphabetical
order.
9.11 Version 2.6 - Feb 17, 1991
- Added RUN WINDOW which shows status of scanning operation.
SCAN/RANK output goes to upper window, status output goes to
lower window.
- Added PAUSE during run. If you type any keystroke while TAS
is scanning a ticker, it will stop at the next ticker and
wait for you to type another key.